package com.sunose.agfmk.examples;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.sunose.agfmk.R;
import com.sunose.agfmk.view.GameView;
/**
 * Created by William Wang on 13-8-30.
 */
public class RotateActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_rotate);
   //work code
//        LinearLayout midLL=(LinearLayout)this.findViewById(R.id.surfacelyid);
//        GameView sv  =new GameView(this);
//        midLL.addView(sv);
  //word code over
        //testing embed surfaceview in layout xml
        GameView sv  =new GameView(this,null);
        SurfaceView svew=(SurfaceView)this.getWindow().getDecorView().findViewById(R.id.surfacelyid);
        ViewGroup parent = (ViewGroup)svew.getParent();
        final int index = parent.indexOfChild(svew);
        parent.removeView(svew);
        parent.removeView(sv);
        parent.addView(sv, index);
//        svew=sv;
//        svew.bringToFront();
//        svew.invalidate();
//        SurfaceHolder sh= sv.getHolder();
//        sh.addCallback((GameView)sv);
//        sv.setWillNotDraw(false);

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    //button quit
    public void buttonQuit(View view)
    {
     this.finish();
    }
}
